export function fileUpload(file: File, size = 2): Promise<string> {
	return new Promise((resolve, reject) => {
		if (!file.type.startsWith('image/')) {
			reject('非图片文件');
			return;
		}
		if (file.size / 1024 / 1024 > size) {
			reject('图片大小不能超过' + size + 'MB');
			return;
		}

		const reader = new FileReader();
		reader.readAsDataURL(file);
		reader.onload = () => resolve(reader.result as string);
		reader.onerror = () => {
			reject('图片解析失败');
		};
	});
}